﻿package net.wangit.adm.log;

import net.wangit.context.ActionContext;
import net.wangit.jdbc.DB;
import net.wangit.jdbc.DBImplementor;
import net.wangit.jdbc.database.Database;
import net.wangit.jdbc.type.TimestampType;
import net.wangit.support.action.TransactionAction;
import net.wangit.util.Checker;

public class DeleteLogAction extends TransactionAction {

	private static final String SQL = "delete from ACCESSLOG where ";

	public DeleteLogAction() {
	}

	public void doAction(DB db, ActionContext ac) throws Exception {
		String date = ac.getRequestParameter("log.list.date");
		if (!Checker.isEmpty(date)) {
			Database database = ((DBImplementor) db).getJDBCSettings()
					.getDatabase();
			net.wangit.jdbc.Type type = new TimestampType();
			String sql = (new StringBuilder("delete from ACCESSLOG where "))
					.append(
							database.getScopeQueryOption(type, null, "curtime",
									null, date)).toString();
			db.execute(sql);
		}
	}
}
